<?php
require_once("../inc/conn.php");
require_once("../inc/session.php");
//接收查询参数  姓名  和  性别
  
	
	  
	  //默认排序
	  if(!empty($_GET["px"])){
		$sort=$_GET["px"]; 
	 }else{
		$sort="desc";
	}
	 
	  
	  
	   if(!empty($_GET["page"])){
		$page=$_GET["page"]; 
	 }else{
		$page=1;
	}
	  
//实现翻页
	  
      
      //查询开始
     $tsql = "select * from shareinfo where name='".$_SESSION["admin"]."' order by dt ".$sort; 
	$trs=$conn->query($tsql);
	 

	  //获取记录总条数
	  $zongtiaoshu=mysql_num_rows($trs);
	  $meiyeshu=10;
	  $zongyeshu= ceil($zongtiaoshu/$meiyeshu);
	  //echo $zongyeshu;
//当前是第几页
	  //记录的起始值  
	  $kaishi=($page-1)*$meiyeshu;

    

      $sql = "select * from shareinfo  where name='".$_SESSION["admin"]."'  order by dt ".$sort." limit $kaishi,$meiyeshu"; 
     $rs=$conn->query($sql);
?>
<!doctype html>
<html>
<meta charset="utf-8" />
<title>显示数据记录</title>
</head>

<body>

<form><table width="98%" border="1" align="center" cellpadding="5">
  <tbody>
    <tr>
      <td colspan="7" align="center">分享列表&nbsp; 【<a href="addshare.php"> 写入信息</a> 】</td>
    </tr>
    <tr>
      <td colspan="7" align="left">总共有<?php echo $zongyeshu?>页，总条数：<?php echo $zongtiaoshu;?>，当前记录是<?php echo $kaishi+1;?>-<?php if($zongtiaoshu<$page*$meiyeshu){echo $zongtiaoshu;}else{echo $page*$meiyeshu;}
	?></td>
    </tr>
    <tr>
      <td width="5%" align="center">序号</td>
      <td width="9%" align="center">所属部门</td>
      <td width="15%" align="center">姓名</td>
      <td width="8%" align="center">数量</td>
      <td width="10%" align="center">来源</td>
      <td width="14%" align="center">时间&nbsp; <a href="?px=asc">&nbsp;升序</a>&nbsp; &nbsp;<a href="?px=desc">降序</a></td>
      <td width="14%" align="center">操作</td>
      </tr>
	  
	<?php
	  $i=0;
while ( $row = mysql_fetch_array($rs, MYSQL_BOTH ) ) {
	$i++;
?> 
    <tr>
      <td align="center"><?php echo $i;?></td>
      <td align="center">
		  
		  <?php 
	      $dsql="select * from department where id=".$row[ "sortid" ];


	      $drs=$conn->query($dsql);


	      $drow=$drs->fetch_assoc();
		  echo $drow["name"];
		  ?>
		
		
		</td>
      <td align="center"><?php echo $row[ "name" ];?></td>
      <td align="center"><?php echo $row[ "num" ];?></td>
		<td align="center">
			
			
			<?php 
	
	if($row[ "type" ]==0){ echo "微信朋友圈";}
	if($row[ "type" ]==1){ echo "QQ空间";}		
			?>
		
		</td>
      <td align="center"><?php echo $row[ "dt" ];?></td>
      <td align="center">&nbsp;<a href="delshare.php?id=<?php echo $row[ "id" ];?>">删除</a>&nbsp;</td>
      </tr>
	  
<?php
	}
?> 
	  
    <tr>
      <td colspan="7">&nbsp; 
		  
		  <?php
		 if($page!=1){
		?>
		   <a href="?page=1">&nbsp;首页</a>
		  &nbsp; &nbsp; 
		  <a href="?page=<?php echo $page-1 ?>">上一页</a>
		  <?php
		 }
		  ?>
		 
		  
		    <?php
		 if($page!=$zongyeshu){
		?>
		  &nbsp; &nbsp; 
		  <a href="?page=<?php echo $page+1 ?>">下一页</a>
		  &nbsp; &nbsp; 
		  <a href="?page=<?php echo $zongyeshu;?>">尾页</a>
		 <?php
		 }
		  ?>
		
	&nbsp;	&nbsp;</td>
    </tr>
  </tbody>
</table></form>
	<script type="text/javascript">
	   function quanxuan（）{
		   
	   }
		
		function fanxuan（）{
		   
	   }
	</script>
</body>
</html>
